package com.jrx.anytxn.param.job.paph.step;

import com.jrx.anytxn.param.constant.Constant;
import com.jrx.anytxn.param.entity.PrOrganizationTable;
import com.jrx.anytxn.param.mapper.ext.ExtTlFilePaymentLogMapper;
import com.jrx.anytxn.param.service.system.IOrganizationTableService;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobExecutionListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

/**
 * @author liuyu
 * @Description 删除tl_file_payment_log中当日提前还款文件数据
 */
@Service
public class ReadPrepayFileListener implements JobExecutionListener {
	@Autowired
	private IOrganizationTableService organizationTableService;
	@Resource
	private ExtTlFilePaymentLogMapper extTlFilePaymentLogMapper;

	@Override
	public void beforeJob(JobExecution jobExecution) {
		PrOrganizationTable org = organizationTableService.findByOrgIdForBatch(Constant.DEFAULT_ORG_NUMBER);
		List<String> list = Arrays.asList(Constant.PREPAY_PAYMENT);
		extTlFilePaymentLogMapper.batchDeleteBydate(org.getNextProcessingDate(), list);
	}

	@Override
	public void afterJob(JobExecution jobExecution) {

	}
}
